﻿<template>
	<video :style="style"></video>
</template>
<script>
	import "/vue/libs/webrtc/libs/adapter.min.js";
	import "/vue/libs/webrtc/webrtcstreamer.js";
	module.exports = {
		name: "webrctVideo",
		data() {
			return {
				webRtcServer: null
			}
		},
		props: {
			url: {
				type: String,
				required:true
			},
			video: {
				type: String,
				required: true
			},
			audio: {
				type: String,
				default: null
			},
			options: {
				type: String,
				default: "rtptransport=tcp&timeout=60"
			},
			style: {
				type: Object,
				default: null
			}
		},
		mounted() {
			this.webRtcServer = new WebRtcStreamer(this.$el, this.url);
			console.info(111, this.webRtcServer, this.video);
			this.webRtcServer.connect(this.video, this.audio, this.options);
		},
		beforeDestroy() {
			this.webRtcServer.disconnect();
		}
	}
</script>